package org.hp.util;

import lombok.Data;

import java.util.List;
import java.util.Map;

@Data
public class ResultJson {
    private Integer code;
    private String msg;
    private Object data;

    public ResultJson(){
    }

    public ResultJson(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    /**
     * 成功的json返回方法
     */
    public static ResultJson success(Integer code, String msg, Object data){//执行成功
        return new ResultJson(code,msg,data);
    }
    public static ResultJson success(Integer code, String msg){//执行成功，不需要返回结果的
        return success(code,msg,null);
    }
    public static ResultJson success(Object data){//执行成功，直接返回结果的
        return success(200,"",data);
    }
    public static ResultJson success(){//执行成功，直接返回结果的
        return success(200,"",null);
    }
    /**
     * 失败的json返回方法
     */
    public static ResultJson error(Integer code,String msg){//执行失败
        return new ResultJson(code,msg,null);
    }
    public static ResultJson error(){//执行失败
        return error(505,"后台错误");
    }
}
